﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/ADAdminLayout.master" AutoEventWireup="true"
    CodeFile="doanh_nghiep.aspx.cs" Inherits="admin_doanh_nghiep" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="block" id="block-tables">
        <div class="content">
            <h2 class="title">
                Doanh Nghiệp</h2>
            <div class="inner">
                <div class="group">
                    <label>
                        Từ khóa:</label>
                    <asp:TextBox ID="TextBox1" runat="server" class="text_field" size="60"></asp:TextBox>
                    
                    <button class="button slim-button" type="submit">
                        <img src="./images/search.png" alt="Tìm kiếm">
                        Tìm kiếm</button>
                </div>
                <br />
                <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
                    AutoGenerateColumns="False" CssClass="table" DataKeyNames="id" DataSourceID="SqlDataSourceDoanhNghiep"
                    Style="margin-right: 31px" CellPadding="4" PageSize="5" AlternatingRowStyle-CssClass="odd" RowStyle-CssClass="even">
<AlternatingRowStyle CssClass="odd"></AlternatingRowStyle>
                    <Columns>
                        
                        <asp:TemplateField ItemStyle-CssClass="first" HeaderText="STT">
                            <ItemTemplate>
                                <%# Container.DataItemIndex + 1 %>
                            </ItemTemplate>

<ItemStyle CssClass="first"></ItemStyle>
                        </asp:TemplateField>
                        <asp:BoundField DataField="ten_doanh_nghiep" HeaderText="Tên doanh nghiệp" SortExpression="ten_doanh_nghiep" />
                        <asp:BoundField DataField="so_dt" HeaderText="Số điện thoại" SortExpression="so_dt" />
                        <asp:BoundField DataField="dia_chi" HeaderText="Địa chỉ" SortExpression="dia_chi" />
                        <asp:BoundField DataField="fax" HeaderText="Fax" SortExpression="fax" />
                        <asp:BoundField DataField="email" HeaderText="Email" SortExpression="email" />
                        <asp:BoundField DataField="ten_dang_nhap" HeaderText="Tên đăng nhập" SortExpression="ten_dang_nhap" />
                        <asp:BoundField DataField="mat_khau" HeaderText="Mật khẩu" SortExpression="mat_khau" />
                        <asp:BoundField DataField="mo_ta" HeaderText="Mô tả" SortExpression="mo_ta" />
                        <asp:CommandField ItemStyle-CssClass="last" ShowEditButton="True"
                            DeleteText="Xóa" EditText="Sửa" UpdateText="Cập nhật" CancelText="Hủy bỏ" 
                            ButtonType="Button">
                            <ControlStyle Font-Size="Small" />

<ItemStyle CssClass="last"></ItemStyle>
                        </asp:CommandField>
                    </Columns>

<RowStyle CssClass="even"></RowStyle>
                </asp:GridView>
                <button class="button" type="button" onclick="$('#ctl00_ContentPlaceHolder1_FormView1').toggle('blind');">
                            Thêm tài khoản mới
                        </button>
                <asp:SqlDataSource ID="SqlDataSourceDoanhNghiep" runat="server" ConnectionString="<%$ ConnectionStrings:babydealConnectionString %>"
                    SelectCommand="SELECT id, ten_doanh_nghiep, so_dt, dia_chi, fax, email, ten_dang_nhap, mat_khau, mo_ta, anh_1 FROM doanh_nghiep WHERE (ten_doanh_nghiep LIKE '%' + @ten_doanh_nghiep + '%') OR (ten_dang_nhap LIKE '%' + @ten_dang_nhap + '%') OR (dia_chi LIKE '%' + @dia_chi + '%')"
                    DeleteCommand="DELETE FROM [doanh_nghiep] WHERE [id] = @id" InsertCommand="INSERT INTO [doanh_nghiep] ([ten_doanh_nghiep], [so_dt], [dia_chi], [fax], [email], [ten_dang_nhap], [mat_khau], [mo_ta], [anh_1]) VALUES (@ten_doanh_nghiep, @so_dt, @dia_chi, @fax, @email, @ten_dang_nhap, @mat_khau, @mo_ta, @anh_1)"
                    
                    UpdateCommand="UPDATE [doanh_nghiep] SET [ten_doanh_nghiep] = @ten_doanh_nghiep, [so_dt] = @so_dt, [dia_chi] = @dia_chi, [fax] = @fax, [email] = @email, [ten_dang_nhap] = @ten_dang_nhap, [mat_khau] = @mat_khau, [mo_ta] = @mo_ta, [anh_1] = @anh_1 WHERE [id] = @id">
                    <DeleteParameters>
                        <asp:Parameter Name="id" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="ten_doanh_nghiep" Type="String" />
                        <asp:Parameter Name="so_dt" Type="String" />
                        <asp:Parameter Name="dia_chi" Type="String" />
                        <asp:Parameter Name="fax" Type="String" />
                        <asp:Parameter Name="email" Type="String" />
                        <asp:Parameter Name="ten_dang_nhap" Type="String" />
                        <asp:Parameter Name="mat_khau" Type="String" />
                        <asp:Parameter Name="mo_ta" Type="String" />
                        <asp:Parameter Name="anh_1" Type="String" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="TextBox1" DefaultValue="%%" Name="ten_doanh_nghiep"
                            PropertyName="Text" Type="String" />
                        <asp:ControlParameter ControlID="TextBox1" DefaultValue="%%" 
                            Name="ten_dang_nhap" PropertyName="Text" />
                        <asp:ControlParameter ControlID="TextBox1" DefaultValue="%%" Name="dia_chi" 
                            PropertyName="Text" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="ten_doanh_nghiep" Type="String" />
                        <asp:Parameter Name="so_dt" Type="String" />
                        <asp:Parameter Name="dia_chi" Type="String" />
                        <asp:Parameter Name="fax" Type="String" />
                        <asp:Parameter Name="email" Type="String" />
                        <asp:Parameter Name="ten_dang_nhap" Type="String" />
                        <asp:Parameter Name="mat_khau" Type="String" />
                        <asp:Parameter Name="mo_ta" Type="String" />
                        <asp:Parameter Name="anh_1" Type="String" />
                        <asp:Parameter Name="id" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            </div>
        </div>
        <br />
        <asp:FormView Style="width: 100%; display: block;" CssClass="block form" ID="FormView1"
            runat="server" DataKeyNames="id" DataSourceID="SqlDataSource1" 
            DefaultMode="Insert" oniteminserted="FormView1_ItemInserted">
            <InsertItemTemplate>
                <div class="content">
                    <h2 class="title">
                        Thêm tài khoản doanh nghiệp</h2>
                    <div class="inner">
                        <div class="group">
                            <label class="label">
                                Tên doanh nghiệp:</label>
                            <asp:TextBox size="70" class="text_field" ID="ten_doanh_nghiepTextBox" runat="server"
                                Text='<%# Bind("ten_doanh_nghiep") %>' />
                        </div>
                        
                        <div class="group">
                            <label class="label">
                                Số điện thoại:</label>
                            <asp:TextBox size="50" class="text_field" ID="so_dtTextBox" runat="server" Text='<%# Bind("so_dt") %>' />
                        </div>
                        <div class="group">
                            <label class="label">
                                Địa chỉ:</label>
                            <asp:TextBox class="text_area" Rows="5" Columns="60" ID="dia_chiTextBox" runat="server"
                                Text='<%# Bind("dia_chi") %>' TextMode="MultiLine" />
                        </div>
                        <div class="group">
                            <label class="label">
                                Fax:</label>
                            <asp:TextBox class="text_field" ID="faxTextBox" runat="server" Text='<%# Bind("fax") %>' />
                        </div>
                        <div class="group">
                            <label class="label">
                                Email:</label>
                            <asp:TextBox class="text_field" ID="emailTextBox" runat="server" Text='<%# Bind("email") %>' />
                        </div>
                        <div class="group">
                            <label class="label">
                                Tên đăng nhập:</label>
                            <asp:TextBox class="text_field" ID="ten_dang_nhapTextBox" runat="server" Text='<%# Bind("ten_dang_nhap") %>' />
                        </div>
                        <div class="group">
                            <label class="label">
                                Mật khẩu:</label>
                            <asp:TextBox class="text_field" ID="mat_khauTextBox" runat="server" Text='<%# Bind("mat_khau") %>' />
                        </div>
                        <div class="group">
                            <label class="label">
                                Mô tả:</label>
                            <asp:TextBox class="text_area" Rows="10" Columns="60" ID="mo_taTextBox" runat="server"
                                Text='<%# Bind("mo_ta") %>' TextMode="MultiLine" />
                        </div>
                        <div class="group">
                            <label class="label">
                                Hình Ảnh:</label>
                            <asp:TextBox class="text_field" ID="anh_1TextBox" runat="server" Text='<%# Bind("anh_1") %>' />
                        </div>
                        <div class="group navform wat-cf">
                            <asp:LinkButton CssClass="button" ID="InsertButton" runat="server" CausesValidation="True"
                                CommandName="Insert" Text="Thêm" />
                            <asp:LinkButton CssClass="text_button_padding link_button" ID="InsertCancelButton"
                                runat="server" CausesValidation="False" CommandName="Cancel" Text="Hủy" />
                        </div>
                    </div>
                </div>
            </InsertItemTemplate>
            <ItemTemplate>
                <asp:Button ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
                    Text="Thêm doanh nghiệp" />
            </ItemTemplate>
        </asp:FormView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:babydealConnectionString %>" 
            DeleteCommand="DELETE FROM [doanh_nghiep] WHERE [id] = @id" 
            InsertCommand="INSERT INTO [doanh_nghiep] ([ten_doanh_nghiep], [so_dt], [dia_chi], [fax], [email], [ten_dang_nhap], [mat_khau], [mo_ta], [anh_1]) VALUES (@ten_doanh_nghiep, @so_dt, @dia_chi, @fax, @email, @ten_dang_nhap, @mat_khau, @mo_ta, @anh_1)" 
            SelectCommand="SELECT * FROM [doanh_nghiep] WHERE ([id] = @id)" 
            UpdateCommand="UPDATE [doanh_nghiep] SET [ten_doanh_nghiep] = @ten_doanh_nghiep, [so_dt] = @so_dt, [dia_chi] = @dia_chi, [fax] = @fax, [email] = @email, [ten_dang_nhap] = @ten_dang_nhap, [mat_khau] = @mat_khau, [mo_ta] = @mo_ta, [anh_1] = @anh_1 WHERE [id] = @id">
            <DeleteParameters>
                <asp:Parameter Name="id" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="ten_doanh_nghiep" Type="String" />
                <asp:Parameter Name="so_dt" Type="String" />
                <asp:Parameter Name="dia_chi" Type="String" />
                <asp:Parameter Name="fax" Type="String" />
                <asp:Parameter Name="email" Type="String" />
                <asp:Parameter Name="ten_dang_nhap" Type="String" />
                <asp:Parameter Name="mat_khau" Type="String" />
                <asp:Parameter Name="mo_ta" Type="String" />
                <asp:Parameter Name="anh_1" Type="String" />
            </InsertParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="GridView1" Name="id" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="ten_doanh_nghiep" Type="String" />
                <asp:Parameter Name="so_dt" Type="String" />
                <asp:Parameter Name="dia_chi" Type="String" />
                <asp:Parameter Name="fax" Type="String" />
                <asp:Parameter Name="email" Type="String" />
                <asp:Parameter Name="ten_dang_nhap" Type="String" />
                <asp:Parameter Name="mat_khau" Type="String" />
                <asp:Parameter Name="mo_ta" Type="String" />
                <asp:Parameter Name="anh_1" Type="String" />
                <asp:Parameter Name="id" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
    </div>
</asp:Content>
